i am unable to understand that how (Number(arr[len]) is composed. is [len] made the property of arr.
function arrayMax(arr) {
var len = arr.length, max = -Infinity;
while (len--) {
if (Number(arr[len]) > max) {
max = Number(arr[len]);
}
}
return max;
};
This is probably some attempt at a super efficient way of getting the max value in a array.
len variable is badly named in all fairness. It should have been labeled index.
function arrayMax(arr) {
var index = arr.length, max = -Infinity;
while (index--) {
if (Number(arr[index]) > max) {
max = Number(arr[index]);
}
}
return max;
};
And arr[index] gets the value at the specified index.